<?php
/* -------------------------------------------------------------------------------------
* 	ID:						$Id: products_new.php 203 2013-09-22 07:59:06Z phone.mueller@googlemail.com $
* 	Letzter Stand:			$Revision: 203 $
* 	zuletzt geaendert von:	$Author: siekiera $
* 	Datum:					$Date: 2013-09-22 07:59:06 +0000 (Sun, 22 Sep 2013) $
*
* 	SEO:mercari by Siekiera Media
* 	http://www.seo-mercari.de
*
* 	Copyright (c) since 2011 SEO:mercari
* --------------------------------------------------------------------------------------
* 	based on:
* 	(c) 2000-2001 The Exchange Project  (earlier name of osCommerce)
* 	(c) 2002-2003 osCommerce - www.oscommerce.com
* 	(c) 2003     nextcommerce - www.nextcommerce.org
* 	(c) 2005     xt:Commerce - www.xt-commerce.com
*
* 	Released under the GNU General Public License
* ----------------------------------------------------------------------------------- */

include ('includes/application_top.php');

$smarty = new Smarty;

require (DIR_FS_CATALOG.'templates/'.CURRENT_TEMPLATE.'/source/boxes.php');
require_once (DIR_FS_INC.'inc.date_long.php');
require_once (DIR_FS_INC.'inc.get_vpe_name.php');

$breadcrumb->add(NAVBAR_TITLE_PRODUCTS_NEW, href_link(FILENAME_PRODUCTS_NEW));

require_once(DIR_WS_INCLUDES.'xajax/xajax_core/xajax.inc.php');
include(DIR_WS_INCLUDES.'xajax/xajax.add_cart.php');
require (DIR_WS_INCLUDES.'header.php');

$products_new_array = array();
$fsk_lock = '';
if ($_SESSION['customers_status']['customers_fsk18_display'] == '0')
	$fsk_lock = ' AND p.products_fsk18 != 1';

if (GROUP_CHECK == 'true')
	$group_check = " AND p.group_permission_".$_SESSION['customers_status']['customers_status_id']." = 1 ";

if (MAX_DISPLAY_NEW_PRODUCTS_DAYS != '0') {
	$date_new_products = date("Y-m-d", mktime(1, 1, 1, date('m'), date('d') - MAX_DISPLAY_NEW_PRODUCTS_DAYS, date('Y')));
	$days = " AND p.products_date_added > '".$date_new_products."' ";
}

include(DIR_WS_MODULES.'product_filter.php');

$products_new_query_raw = "SELECT DISTINCT
								p.products_id,
								p.products_quantity,
								p.products_fsk18,
								pd.products_name,
								pd.products_short_description,
								p.products_image,
								p.products_price,
								p.products_vpe,
								p.products_vpe_status,
								p.products_vpe_value,
								p.products_tax_class_id,
								p.products_date_added,
								b.brand_name
							FROM
								".TABLE_PRODUCTS." p
							LEFT JOIN
								".TABLE_BRAND." b
								ON
									p.brand_id = b.brand_id
							LEFT JOIN
								".TABLE_PRODUCTS_DESCRIPTION." pd
								ON
									p.products_id = pd.products_id,
								".TABLE_CATEGORIES." c,
								".TABLE_PRODUCTS_TO_CATEGORIES." p2c
							WHERE
								pd.language_id = '".(int)$_SESSION['languages_id']."'
							AND
								c.categories_status=1
							AND
								p.products_id = p2c.products_id
							AND
								c.categories_id = p2c.categories_id
							AND
								products_status = '1'
								".$filter_products.$group_check.$fsk_lock.$days."
							ORDER BY
								p.products_date_added DESC";

$listing = new page_break($products_new_query_raw, $_GET['page'], true, FILENAME_PRODUCTS_NEW, 'new_products_overview');

if($listing->result) {
	$module_smarty = new Smarty();
	$module_content = '';
	$i=0;
	while (!$listing->sql_string->EOF) { $rows++;
		if($listing->listName == 'mosaic' && empty($listing->sql_string->fields['products_image'])) {}
		else $module_content[] = $product->buildDataArray($listing->sql_string->fields, 'thumbnail', $listing->listData, $rows);
		$listing->sql_string->MoveNext();
	}
	
	include(DIR_WS_MODULES.'page_view_as.php');
	include(DIR_WS_MODULES.'page_per_site.php');
	include(DIR_WS_MODULES.'page_mulit_sort.php');
	include(DIR_WS_MODULES.'page_brand.php');
	$module_smarty->assign('NAVIGATION', $listing->getLinks());
	$module_smarty->assign('LIST_NAME', $listing->page_name);
	$module_smarty->assign('CLASS_NAME', $listing->listName);
	$module_smarty->assign('module_content', $module_content);

} else {
	$error = TEXT_PRODUCT_NOT_FOUND;
	include(DIR_WS_MODULES.FILENAME_ERROR_HANDLER);
}

$module_smarty->assign('language', $_SESSION['language']);
$module_smarty->caching = false;
$module_smarty->assign('TITLE', NEW_PRODUCTS_OVERVIEW);

$module = $module_smarty->fetch(CURRENT_TEMPLATE.'/module/'.$listing->listData['list_file'].'.html');
$smarty->assign('main_content', $module);

$smarty->assign('language', $_SESSION['language']);
$smarty->caching = false;
if (!defined('RM'))
	$smarty->loadFilter('output', 'note');
$smarty->loadFilter('output','trimwhitespace');
$smarty->display(CURRENT_TEMPLATE.'/index.html');
include ('includes/application_bottom.php');
?>